#Author : Floriane Simonet
#e-mail : simonet.floriane@gmail.com
#! usr/bin/perl -w
use strict;


sub read_SNPselectfile{

	my $SNPselectfile=$_[0];
	my @chrlist=(1..26);
	my $i=0;
	my $currentchr=$chrlist[$i];

	open(SNPSELECTFILE, $SNPselectfile) or die "cannot open $SNPselectfile";
	while(my $line=<SNPSELECTFILE>)
	{
		#my $currentchr=$chr;
		chomp($line);
		my($chr,$rsID,$cMpos,$BPpos,$a1,$a2)=split(/\t/,$line);
		if($chr == $currentchr){
			print $chr."\n";
			print $currentchr."\n";
			#verifier que la BPpos_snp_av - BPpos_snp_ap < 10e6
			print $rsID."\n";
		}
		else{
			$i++;
			print "i : ".$i."\n";
			$currentchr=$chrlist[$i];
			print "dans le else ".$currentchr."\n";
			print $rsID."\n";
		}
	}
	close SNPSELECTFILE;
}

############################################################

sub main(){
	
	# collect arguments
	my $SNPselectfile=$ARGV[0]; # SNPs selected for replication
	
	if(-f $SNPselectfile){
		&read_SNPselectfile($SNPselectfile);
	}
	else{
			print "$SNPselectfile doesn't exist.\n";
	}
exit;
}

main();

# command line example : perl imputation.pl ../newbimfile_mitral.input_10252011.out
